<%@ page language="java" contentType="text/html; charset=utf8"
	pageEncoding="utf8"%>
<%@taglib uri="http://www.springframework.org/tags" prefix="spring"%>
<%@taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf8">
	<link type="text/css" href="resources/css/jquery-ui.css" 		rel="stylesheet" />
	<link type="text/css" href="resources/css/flexigrid.css" 		rel="stylesheet">
	<link type="text/css" href="resources/css/main.css" 			rel="stylesheet"/>
	<link type="text/css" href="resources/css/ui.jqgrid.css"  media="screen" 	rel="stylesheet" />
	
	<script type="text/javascript" src="resources/jquery.min.js"></script>
	<script type="text/javascript" src="resources/jquery-ui.min.js"></script>
	<script type="text/javascript" src="resources/flexigrid.js"></script>
	
	<script type="text/javascript" src="resources/i18n/grid.locale-en.js" ></script>
	<script type="text/javascript" src="resources/jquery.jqGrid.src.js" ></script>
	<title><spring:message code="label.title" /></title>
	
	<script type="text/javascript">
		/* ---------------------------------------------- */
		
		function loadList() {
			$('#unregisteredRegistryList').
				load('unregisteredRegistryList', 
						/* Add filtes */
						{  _pRegionName: 	$("#pRegionName").attr("value") , 
						   _pLocalityName:	$("#pLocalityName").attr("value") ,
						   _pSupportType:	$("#pSupportType").attr("value"),
						   _pLight:			$("#pLight").attr("checked"),
						   _pAddresString:	$("#pAddresString").attr("value"), 
						   _pPriceFrom:		$("#pPriceFrom").attr("value"),
						   _pPriceTo:		$("#pPriceTo").attr("value")
						 }
							
					);
		};

		
		$(document).ready(function(){
			loadList();
			$("#btApplyFilter").click(function(event){
				loadList();	
			});

// Add AUTOCOMPLETE functionality for filters panel			
			 $("#pRegionName").autocomplete(
				       {
				           source : function(request, response) {
				               $.ajax({
				                   url : "json/distinct/region",
				                   dataType : "json",
				                   data : {
				                       term : request.term
				                   },
				                   success : function(data) {
				                       response($.map(data , function(item) {
				                           return {
				                               label : item.regionName,
				                               value : item.regionName
				                           }
				                       }));
				                   }
				               });
				           },
				           minLength : 1
				       });			
			
			 
			 $("#pLocalityName").autocomplete(
				       {
				           source : function(request, response) {
				               $.ajax({
				                   url : "json/distinct/locality",
				                   dataType : "json",
				                   data : {
				                       term : request.term
				                   },
				                   success : function(data) {
				                       response($.map(data , function(item) {
				                           return {
				                               label : item.localityName,
				                               value : item.localityName
				                           }
				                       }));
				                   }
				               });
				           },
				           minLength : 1
				       });
			 
			 $("#pSupportType").autocomplete(
				       {
				           source : function(request, response) {
				               $.ajax({
				                   url : "json/distinct/supportType",
				                   dataType : "json",
				                   data : {
				                       term : request.term
				                   },
				                   success : function(data) {
				                       response($.map(data , function(item) {
				                           return {
				                               label : item.supportTypeName,
				                               value : item.supportTypeName
				                           }
				                       }));
				                   }
				               });
				           },
				           minLength : 1
				       });
// Add AUTOCOMPLETE functionality for filters panel			 
			 
		});
		
		
		
		
		
// 	     $(document).ready(function(){
// 	         $("a").click(function(event){
// 	           alert("As you can see, the link no longer took you to jquery.com");
// 	           event.preventDefault();
// 	         });
// 	      });		
		  
		
	</script>	
</head>
<body>
	<div id="header">
	  <div class="center">
	    <div id="logo"><a href="#">STANDART</a></div>
	   </div>
	</div>
	<c:if test="${not empty param.error}">
		<font color="red"> <spring:message code="label.loginerror" />
		: ${sessionScope["SPRING_SECURITY_LAST_EXCEPTION"].message} </font>
	</c:if>
	
	
<!-- BEGIN Login Form Declaration	 -->
	<div align="right">
		<form method="POST" action="<c:url value="/j_spring_security_check" />">
			<table>
				<tr>
					<td align="right"><spring:message code="label.login" /></td>
					<td><input type="text" name="j_username" /></td>
					<td align="right"><spring:message code="label.password" /></td>
					<td><input type="password" name="j_password" /></td>
					<td  align="right"><input type="submit" value="Login" />
				</td>	
				<tr>	
					<td> &nbsp;</td>
					<td align="right"><spring:message code="label.remember" /></td>
					<td><input type="checkbox" name="_spring_security_remember_me" /></td>
					<td> <a href="<c:url value="/registration" />">
							<spring:message code="label.registration" />
						</a>
					</td>
					<td><input type="reset" value="Reset" /></td>
				</tr>
			</table>
		</form>
	</div>
<!-- END Login Form Declaration	 -->
			<div class="ui-jqgrid ui-jqgrid-titlebar ui-widget-header ui-corner-top ui-helper-clearfix"
						style="padding: .2em .2em .2em .2em;" >
				<span class="ui-jqgrid-title" style="font-size: 0.9em;">Filtration parameters</span>
			</div>
			<div id="filtrationPanel" class="ui-userdata ui-state-default" style="padding: .2em .2em .2em .2em;">
				<table id="prm" style="width: 100%" border="0">
					<tr>
						<td align="right">Support type:</td>
						<td><input type="text" id="pSupportType" class="ui-widget" ></td>
						<td>&nbsp;</td>
						<td align="right">Region:</td>
						<td><input type="text" id="pRegionName" class="ui-widget" ></td>
						<td>&nbsp;</td>
						<td align="right">Addres:</td>
						<td colspan="2">
							<input type="text" id="pAddresString" class="ui-widget"></td>
<!-- 						<td>&nbsp;</td> -->
						<td align="right">&nbsp;</td>
						<td><input id="btApplyFilter" type="button" value="Apply Filter"></td>
					</tr>
					<tr>
						<td align="right">Ligt:</td>
						<td><input type="checkbox" id="pLight" ></td>						
						<td>&nbsp;</td>
						<td align="right">Locality:</td>
						<td><input type="text" id="pLocalityName"  class="ui-widget" ></td>
						<td>&nbsp;</td>
						<td align="right">Price:</td>
						<td>
							<input type="text" id="pPriceFrom" class="ui-widget" >
							<input type="text" id="pPriceTo"   class="ui-widget" >
						</td>
						<td>&nbsp;
							
						</td>
						<td align="right">&nbsp;</td>
						<td><input id="btResetFilter" type="button" value="Reset Filter"></td>
					</tr>	
					<tr>							
						<td align="right">
							Prezentation:
						</td>
						<td colspan="2" >
							<input type="radio" checked="checked" name="rbPresentation" value="table">Tabel
							<input type="radio" name="rbPresentation" value="gril">Grila
						</td>							
						<td colspan="8" align="left">
							Pager
						</td>
					</tr>
				</table> 
			</div>
			
	<div id="unregisteredRegistryList">
	
	
	
	</div>
</body>
</html>